package com.fh.service.expand;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.fh.dao.DaoSupport;
import com.fh.entity.Event;
import com.fh.entity.Page;
import com.fh.util.PageData;


@Service("eventService")
public class EventService {

	@Resource(name = "daoSupport")
	private DaoSupport dao;
	
	/*
	* 新增
	*/
	public void save(PageData pd)throws Exception{
		boolean hasTime = pd.containsKey("createTime");
		if(!hasTime){
			pd.put("createTime", new Date());
		}
		dao.save("EventMapper.save", pd);
	}
	
	/*
	* 删除
	*/
	public void delete(PageData pd)throws Exception{
		dao.delete("EventMapper.delete", pd);
	}
	
	/*
	* 修改
	*/
	public int edit(Event event)throws Exception{
		return dao.update("EventMapper.edit", event);
	}
	
	/*
	*列表(按创建时间倒序排列)
	*/
	public List<Event> list(Page page)throws Exception{
		return (List<Event>)dao.findForList("EventMapper.datalistPage", page);
	}
	
	/*
	*列表(全部)
	*/
	public List<Event> listAll(PageData pd)throws Exception{
		return (List<Event>)dao.findForList("EventMapper.listAll", pd);
	}
	
	/*
	* 通过id获取数据
	*/
	public Event findById(PageData pd)throws Exception{
		Object oj = dao.findForObject("EventMapper.findById", pd);
		return (Event)oj;
	}
	
	
	/*
	* 通过id获取数据
	*/
	public Event findById1(Long id)throws Exception{
		Object oj = dao.findForObject("EventMapper.findById1", id);
		return (Event)oj;
	}
	
	/*
	* 批量删除
	*/
	public void deleteAll(String[] ArrayDATA_IDS)throws Exception{
		dao.delete("EventMapper.deleteAll", ArrayDATA_IDS);
	}
	
}

